package xworker.gluon.glisten.control;

import com.gluonhq.charm.glisten.control.Toast;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.util.JavaFXUtils;

public class ToastActions {
    public static void init(Toast node , Thing thing, ActionContext actionContext){
        MessageActions.init(node, thing, actionContext);
    }

    public static Toast create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        String message = JavaFXUtils.getObject(self, "message", actionContext);
        Toast node = new Toast(message);
        init(node, self, actionContext);

        actionContext.peek().put("parent", node);
        for (Thing child : self.getChilds()) {
            child.doAction("create", actionContext);
        }

        actionContext.g().put(self.getMetadata().getName(), node);
        return node;
    }
}
